package com.zdy.state;

/**
 * Created by 逸足天涯
 * on 3/9/2020.
 */
public class TestDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        Thread thread = new Thread(god);
        thread.setDaemon(true);//默认为false用户线程，这里改为守护线程

        thread.start();
        new Thread(you).start();
    }
}

class God implements Runnable{
    @Override
    public void run() {
        while(true) {
            System.out.println("上帝保佑你");
        }
    }
}
class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("开开心心每一天");
        }
        System.out.println("+++++good world++++");
    }
}
